package com.vxdata.utils.modules.utils.security;

/**
 * 秒 转 中文描述
 */
public class DateUtils {
    /**
     * 返回日时分秒
     *
     * @param second 秒
     * @return
     */
    public static String secondToTime(long second) {
        long days = second / 86400;//转换天数
        second = second % 86400;//剩余秒数

        long hours = second / 3600;//转换小时数
        second = second % 3600;//剩余秒数

        long minutes = second / 60;//转换分钟
        second = second % 60;//剩余秒数

        StringBuilder builder = new StringBuilder();
        if (days > 0) {
            builder.append(days);
            builder.append("天");
        }
        if (hours > 0) {
            builder.append(hours);
            builder.append("小时");
        }
        if (minutes > 0) {
            builder.append(minutes);
            builder.append("分");
        }
        if (second > 0) {
            builder.append(second);
            builder.append("秒");
        }
        return builder.toString();
    }
}
